const install = (Vue) => {
  /**
   * dialog 弹窗
   * @param {String} content 提示文字内容
   * @param {String} title 提示标题
   * @param {Boolean} showCancel 是否显示取消按钮
   * @param {String} confirmText 确定按钮文字
   * @param {String} cancelText 取消按钮文字
   */
  Vue.prototype.$dialog = (content, showCancel = false, title = '提示', confirmText = '确定', cancelText = '取消') => {
    return new Promise((resolve, reject) => {
      uni.showModal({
        title,
        content,
        showCancel,
        confirmText,
        cancelText,
        success: (result) => {
          if (result.confirm) { resolve() }
          else { reject() }
        },
        fail: () => { reject() }
      })
    })
  }
}

export default {
  install
}